#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename	:  04-ext4.sh
# Version	:  1.0
# Date		:  2025/02/06
# Author	:  yaoxiyao
# Email		:  yaoxiyao@kylinos.com.cn
# Function	:  GN-WJXT_003文件系统信息
# Out		:
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

# 测试主题
Title_Env_LTFLIB="GN-WJXT_003文件系统信息"

## TODO : 个性化,初始化
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestInit_LTFLIB() {
    return $TPASS
}

## TODO : 清理函数
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestClean_LTFLIB() {
    return $TPASS
}

## TODO : 测试用例集
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
Testsuite_LTFLIB() {
    testcase_1
    return $TPASS
}

## TODO ： GN-WJXT_003文件系统信息
testcase_1() {
    local dev_ext4=($(df -Th | grep ext4 | awk '{print $1}'))
    local dev_xfs=($(df -Th | grep xfs | awk '{print $1}'))
    if [ ${#dev_ext4[@]} -ne 0 ]; then
        for i in ${dev_ext4[@]}; do
            dumpe2fs "${i}" | head -n 20
            CommRetParse_LTFLIB "dumpe2fs ${i} | head -n 20"
        done
    else
        Info_LLE "本系统无ext4文件系统"
    fi
    if [ ${#dev_xfs[@]} -ne 0 ]; then
        for j in ${dev_xfs[@]}; do
            xfs_info "${j}" | head -n 20
            CommRetParse_LTFLIB "xfs_info ${j} | head -n 20"
        done
    else
        Info_LLE "本系统无xfs文件系统"
    fi
}

#----------------------------------------------#

source "${LIB_LTFLIB}"
Main_LTFLIB $@
